package com.iflysse.controller;


import com.iflysse.common.ResultEnum;
import com.iflysse.pojo.bo.resp.ClassBoResp;
import com.iflysse.pojo.bo.resp.ClassListBoResp;
import com.iflysse.pojo.vo.resp.ClassListVoResp;
import com.iflysse.pojo.vo.resp.ClassResp;
import com.iflysse.services.IClassService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;

@RestController
@RequestMapping("/class")
@Api(value = "老师端班级接口")
public class ClassController {

    @Autowired
    IClassService classService;

    @PostMapping("/queryAllAdministrativeClass")
    @ApiOperation("查询所有的行政班级")
    public ClassListVoResp doQueryAllAdministrativeClass() {

        ClassListVoResp classListVoResp=new ClassListVoResp();
        try{
            ClassListBoResp classListBoResp = classService.loadAllClasses();
            List<ClassBoResp> list = classListBoResp.getClassBoRespList();
            List<ClassResp> result = new ArrayList<>();
            for(int i=0;i<list.size();i++){
                ClassBoResp classBoResp = list.get(i);
                ClassResp classResp = new ClassResp();
                classResp.setClassName(classBoResp.getClassName());
                result.add(classResp);
            }
            classListVoResp.setResult(result);
            //设置返回码和返回信息
            classListVoResp.setCode(ResultEnum.SUCCESS.getCode());
            classListVoResp.setMsg(ResultEnum.SUCCESS.getMsg());

        }catch(Exception e){
            e.printStackTrace();
            classListVoResp.setCode(ResultEnum.ERROR.getCode());
            classListVoResp.setMsg(ResultEnum.ERROR.getMsg());
        }
        return classListVoResp;
    }


    @PostMapping("/queryAllTeachingClass")
    @ApiOperation("老师端添加学生时获取所有的教学班级得下拉列表")
    public ClassListVoResp doQueryAllTeachingClass() {

        ClassListVoResp classListVoResp = new ClassListVoResp();
        return classListVoResp;
    }
}
